Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Jan 19, 2026

Summary

Adds superuser capability to debug workflows

Type of Change

  • New feature

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 20, 2026 0:20am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

This PR adds a toggleable debug mode for superusers that allows importing workflows by ID for debugging purposes. The implementation introduces a two-factor authentication pattern where superuser features require both the database isSuperUser flag AND the superUserModeEnabled setting toggle.

Key Changes:

  • introduced verifyEffectiveSuperUser helper that checks both conditions, replacing the old verifySuperUser function
  • new /api/superuser/import-workflow endpoint that copies workflows with copilot chats to target workspace
  • Debug settings panel in workflow settings modal, visible only to effective superusers
  • refactored all existing superuser checks across template and creator endpoints to use the new effective superuser pattern
  • fixed typo edit_responsdedit_respond in tool-call component

Note: Previous thread identified missing user feedback in the Debug component (silent success/failure). This wasn't addressed in the current changes.

Confidence Score: 4/5

  • safe to merge with minor UX concern
  • the core implementation is solid with proper permission checks, error handling, and cleanup on failure - the only issue is missing user feedback in the Debug component (already noted in previous thread), which affects UX but not functionality or security
  • pay attention to apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/debug/debug.tsx - missing user feedback on import success/failure

Important Files Changed

Filename Overview
apps/sim/lib/templates/permissions.ts introduced verifyEffectiveSuperUser helper that checks both database flag and settings toggle - clean refactor
apps/sim/app/api/superuser/import-workflow/route.ts new endpoint to import workflows by ID with copilot chats - properly uses effective superuser check and cleans up on failure
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/debug/debug.tsx debug UI component for importing workflows - missing user feedback on import success/failure (previous thread issues)
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/settings-modal.tsx added Debug navigation item and superuser section, properly conditionally shows based on both isSuperUser flag and setting

Sequence Diagram

sequenceDiagram
    participant User
    participant DebugUI as Debug Component
    participant API as /api/superuser/import-workflow
    participant PermCheck as verifyEffectiveSuperUser
    participant DB as Database
    participant WorkflowOps as Workflow Operations

    User->>DebugUI: Enter workflow ID & click Import
    DebugUI->>API: POST {workflowId, targetWorkspaceId}
    API->>PermCheck: Check superuser access
    PermCheck->>DB: Query user.isSuperUser
    PermCheck->>DB: Query settings.superUserModeEnabled
    PermCheck-->>API: {effectiveSuperUser: true/false}
    
    alt Not Effective Superuser
        API-->>DebugUI: 403 Forbidden
        DebugUI->>DebugUI: Log error (no user feedback)
    else Effective Superuser
        API->>DB: Verify target workspace exists
        API->>DB: Fetch source workflow
        API->>WorkflowOps: loadWorkflowFromNormalizedTables
        API->>WorkflowOps: sanitizeForExport
        API->>WorkflowOps: parseWorkflowJson (regenerate IDs)
        API->>DB: Create new workflow record
        API->>WorkflowOps: saveWorkflowToNormalizedTables
        
        alt Save Failed
            API->>DB: Delete workflow record (cleanup)
            API-->>DebugUI: 500 Error
        else Save Success
            API->>DB: Copy copilot chats
            API-->>DebugUI: 200 {newWorkflowId, copilotChatsImported}
            DebugUI->>DebugUI: Invalidate workflow list query
            DebugUI->>DebugUI: Clear input & log (no user feedback)
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator

@greptile

@Sg312 Sg312 merged commit e575ba2 into staging Jan 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants